﻿using System;
using System.IO;
using NUnit.Framework;
using Smartkernel.IO;

namespace Smartkernel.NUnitTest.IO
{
    [Category("IO")]
    [TestFixture]
    public class SmartRarTest
    {
        [Test]
        public void Test()
        {
            ////【01】压缩文件（涉及方法：Compress）
            //string appPath = @"C:\Program Files\WinRAR\WinRAR.exe";
            //string path1 = @"C:\SmartRarTest" + DateTime.Now.Ticks.ToString() + ".txt";
            //if (!File.Exists(path1))
            //{
            //    using (StreamWriter streamWriter = File.CreateText(path1))
            //    {
            //        for (int i = 0; i < 1000; i++)
            //        {
            //            streamWriter.WriteLine(DateTime.Now.Ticks.ToString());
            //        }
            //    }
            //}
            //string path2 = @"C:\SmartRarTest" + DateTime.Now.Ticks.ToString() + ".rar";
            //SmartRar.Compress(appPath, path1, path2, "123");
            //System.Threading.Thread.Sleep(3000);

            ////【02】解压缩文件（涉及方法：Decompress）
            //File.Delete(path1);
            //SmartRar.Decompress(appPath, path2, @"C:\", "123");
            //System.Threading.Thread.Sleep(3000);
            //File.Delete(path1);
            //File.Delete(path2);

            ////【03】压缩文件夹
            //string sourceFolder = @"C:\WINDOWS\system";
            //string targetPath = @"C:\SystemDemotest.rar";
            //SmartRar.Compress(appPath, sourceFolder, targetPath);
            //System.Threading.Thread.Sleep(3000);

            ////【04】解压缩文件夹
            //SmartRar.Decompress(appPath, @"C:\SystemDemotest.rar", @"C:\Test");
            //System.Threading.Thread.Sleep(3000);
            //File.Delete(targetPath);
            //Directory.Delete(@"C:\Test");
        }
    }
}
